package com.ychug.framework.core.advice;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ychug.framework.core.tag.TagBase;
import com.ychug.framework.web.page.TableDataInfo;
import com.ychug.service.system.entity.SysConfigEntity;
import com.ychug.service.system.service.ISysConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Component
public class AdDirective  extends TagBase {

    @Autowired
    private ISysConfigService iSysConfigService;

    @Override
    public void onRender() {
//        Map<String,Object> parmas = new HashMap<String,Object>();
//        parmas.put("pageNum",getParam("pageNum"));
//        parmas.put("pageSize",getParam("pageSize"));
        System.out.println(getParam("pageNum") +"" + getParam("pageSize"));

        int pageNum = getPageNum(); //getParam("pageNum") != null ?Integer.parseInt(getParam("pageNum")):0;
        int pageSize =  getParam("pageSize") != null ?Integer.parseInt(getParam("pageSize")):0;
        PageHelper.startPage(pageNum, pageSize);
        List<SysConfigEntity> sysConfigEntityList = iSysConfigService.selectConfigList(new SysConfigEntity());

        PageInfo<SysConfigEntity> tPageInfo = new PageInfo(sysConfigEntityList);

        setVariable("ad", sysConfigEntityList);
        setVariable("page", tPageInfo);
        renderBody();
    }
}
